package com.gangquan360.smartadmin.module.samplesend.controller;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.module.samplesend.domain.dto.SampleSendDTO;
import com.gangquan360.smartadmin.module.samplesend.domain.dto.SampleSendQueryDTO;
import com.gangquan360.smartadmin.module.samplesend.domain.dto.SampleSendTrackDTO;
import com.gangquan360.smartadmin.module.samplesend.domain.dto.SampleSendTrackLogDTO;
import com.gangquan360.smartadmin.module.samplesend.service.SampleSendService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * [ 产品送样表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-28 17:47:14
 * @since JDK1.8
 */
@RestController
@Api(tags = {"产品送样表"})
public class SampleSendController {

    @Autowired
    private SampleSendService sampleSendService;

    @ApiOperation(value = "分页查询产品送样表",notes = "@author wiggin")
    @PostMapping("/sampleSend/page/query")
    public ResponseDTO<PageResultDTO<SampleSendDTO>> queryByPage(@RequestBody SampleSendQueryDTO queryDTO) {
        return sampleSendService.queryByPage(queryDTO);
    }

    @ApiOperation(value = "添加产品送样表",notes = "@author wiggin")
    @PostMapping("/sampleSend/add")
    public ResponseDTO<String> add(@RequestBody @Valid SampleSendDTO addTO){
        return sampleSendService.add(addTO);
    }

    @ApiOperation(value="修改产品送样表",notes = "@author wiggin")
    @PostMapping("/sampleSend/update")
    public ResponseDTO<String> update(@RequestBody @Valid SampleSendDTO updateDTO){
        return sampleSendService.update(updateDTO);
    }


    @ApiOperation(value="删除产品送样表",notes = "@author wiggin")
    @GetMapping("/sampleSend/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return sampleSendService.delete(id);
    }


    @ApiOperation(value="详情产品送样表",notes = "@author wiggin")
    @GetMapping("/sampleSend/detail/{id}")
    public ResponseDTO<SampleSendDTO> detail(@PathVariable("id") Long id){
        return sampleSendService.detail(id);
    }
    
    @ApiOperation(value="新增跟踪日志", notes="@author wiggin")
    @PostMapping("/sampleSend/tacklog/add")
    public ResponseDTO<String> addTrack(@RequestBody @Valid SampleSendTrackDTO sampleSendTrackDTO) {
    	return sampleSendService.addTrack(sampleSendTrackDTO);
    }
    
    @GetMapping("/sampleSend/tracklog/list/{id}")
    public ResponseDTO<List<SampleSendTrackLogDTO>> getTrackList(@PathVariable("id") Long id) {
    	return sampleSendService.getTrackList(id);
    }
}
